import { defineComponent, h } from 'vue'

export default defineComponent({
  name: 'GeneratorForm',
  props: {
    formConfig: {
      type: Object,
      default: () => ({})
    }
  },
  setup(props, { emit }) {
    const formItemRender = () => {
      return props.formConfig.map((item: any) => {
        const { label, name, Tag = 'a-input' } = item
        return (
          <a-form-item label={label} name={name}>
            <Tag v-model={[item.value, name]} />
          </a-form-item>
        )
      })
    }

    return () => {
      return (
        <a-form>
          { formItemRender() }
        </a-form>
      )
    }
  }
})
